<%--
  Created by IntelliJ IDEA.
  User: DE
  Date: 2019/4/9
  Time: 17:47
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>主页</title>
    <link href="<%=basePath%>resources/layui/css/layui.css" rel="stylesheet"></link>
    <link href="<%=basePath%>resources/css/style.css" rel="stylesheet"></link>

    <style>
        .layui-fixbar{
            width: 40px;
        }

    </style>
</head>
<body>
 <!-- layout admin -->
 <div class="layui-layout layui-layout-admin"> <!-- 添加skin-1类可手动修改主题为纯白，添加skin-2类可手动修改主题为蓝白 -->
     <!-- header -->
     <div class="layui-header my-header">
         <a href="<c:if test="${user.usertype==1}">/order/orderlist</c:if><c:if test="${user.usertype==0}">/page/manager/orderManager</c:if>">
             <!--<img class="my-header-logo" src="" alt="logo">-->
             <div class="my-header-logo">校园便捷服务平台</div>
         </a>


         <!-- 顶部右侧添加选项卡监听 -->
         <ul class="layui-nav my-header-user-nav" lay-filter="side-top-right">
             <li class="layui-nav-item"><span id="datetime"></span>&nbsp;</li>
             <li class="layui-nav-item">
                 <a href="<c:if test="${user.usertype==1}"><%=basePath%>order/orderlist</c:if><c:if test="${user.usertype==0}"><%=basePath%>page/manager/orderManager</c:if>">主页</a>
             </li>
             <li class="layui-nav-item">
                 <a href="<%=basePath%>order/acceptOrderlist">我的订单<!--<span class="layui-badge">9</span>--></a>
             </li>
             <li class="layui-nav-item">
                 <a href="<%=basePath%>page/user/personalCenter">个人中心<!--<span class="layui-badge-dot"></span>--></a>
             </li>
             <li class="layui-nav-item">
                 <a href="<%=basePath%>page/user/personalCenter"><c:if test="${user.userimg!=null}"><img src="<%=basePath%>${user.userimg}" class="layui-nav-img"></c:if>${user.username}</a>
                 <dl class="layui-nav-child">
                     <dd><a href="javascript:;" onclick="logout()">退出系统</a></dd>
                 </dl>
             </li>
         </ul>

     </div>
     <!-- body -->
     <div class="layui-body my-body"  style="background-color: #F6F6F6">

         <div class="layui-tab-content">
             <c:set var="sessionUserId" value="${sessionScope.user.userid}"/>
             <c:forEach items="${orderlist}" var="d">
                 <div class="layui-tab-item layui-show my-card" style="background-color: white;margin: 10px 20% ">
                     <div class="layui-card-header" style="margin-top: 10px;font-weight:bolder; font-size: 125%;"><a href="<%=basePath%>order/orderMessage?id=${d.id}" >${d.ordertitle}</a><c:if test="${d.finishstatus==1}"><c:if test="${d.commentstatus==0}"><span style="color: red">未评论</span></c:if></c:if><c:if test="${d.userimg!=null}">&nbsp;<img src="<%=basePath%>${d.userimg}" class="layui-nav-img"></c:if>&nbsp;${d.releaseusername}</div>
                     <div class="layui-card-body" style="margin-top: 10px">
                             ${d.orderbody}
                     </div>
                     <div>

                         <c:if test="${d.userid!=sessionUserId}">
                             <c:choose>
                                 <c:when test="${d.accpetstatus==0}">
                                     <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px;color: white" > <a href="<%=basePath%>order/acceptOrder?id=${d.id}" style="color: white;">接受订单</a></button>

                                 </c:when>
                                 <c:when test="${d.finishstatus==0&&d.accpetstatus==1}">
                                     <button class="layui-btn layui-btn-sm layui-col-md-offset10" id="finishOrderbtn"  style="margin-bottom: 10px;color: white" > <a href="<%=basePath%>order/finishOrder?id=${d.id}" style="color: white;">完成订单</a></button>
                                 </c:when>

                                 <c:otherwise>
                                     <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px;color: white"> <a href="<%=basePath%>order/orderMessage?id=${d.id}" style="color: white;">查看订单</a></button>

                                 </c:otherwise>
                             </c:choose>
                         </c:if>
                         <c:if test="${d.userid==sessionUserId}">
                             <c:choose>
                             <c:when test="${d.accpetstatus==0}">
                                 <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px;color: white"> <a href="<%=basePath%>order/cancelOrder?id=${d.id}" style="color: white;">取消订单</a></button>
                             </c:when>
                             <c:when test="${d.accpetstatus==1&&d.finishstatus==0}">
                                 <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px;color: white"> <a href="<%=basePath%>order/orderMessage?id=${d.id}" style="color: white;">查看订单</a></button>
                             </c:when>

                             <c:when test="${d.finishstatus==1&&d.commentstatus==0}">
                                 <button class="layui-btn layui-btn-sm layui-col-md-offset10"  id="commentOrderbtn" style="margin-bottom: 10px;color: white" ><a href="<%=basePath%>order/orderMessage?id=${d.id}" style="color: white;">评论</a></button>
                             </c:when>

                             <c:otherwise>
                                 <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px;color: white"> <a href="<%=basePath%>order/orderMessage?id=${d.id}" style="color: white;">查看订单</a></button>
                             </c:otherwise>

                             </c:choose>
                         </c:if>

                     </div>
                 </div>

             </c:forEach>



         </div>


     </div>

 </div>
 <script type="text/javascript" src="<%=basePath%>resources/jquery-3.2.1/jquery-3.2.1.js" ></script>
 <script src="<%=basePath%>resources/layui/layui.js"></script>
 <script src="<%=basePath%>resources/js/vip_comm.js"></script>
 <script src="<%=basePath%>resources/js/functionList.js"></script>
 <script type="text/javascript">
     layui.use(['layer', 'laytpl', 'rate'], function () {

         // 操作对象
         var layer = layui.layer
             ,laytpl = layui.laytpl
             ,rate=layui.rate
             , $ = layui.jquery;

         // 顶部左侧菜单生成 [请求地址,过滤ID,是否展开,携带参数]
         //vipNav.top_left('./json/nav_top_left.json','side-top-left',false);
         // 主体菜单生成 [请求地址,过滤ID,是否展开,携带参数]
         //vipNav.main('./json/nav_main.json','side-main',true);

         // you code ...


         var commentStart = rate.render({
             elem: '#commentStart'
             ,choose: function(value){
                 $.get("<%=basePath%>order/commentOrder?id=${d.id}",value,function(data){
                     layer.msg(data.msg());

                 });

         }
         });





     });


     writeDateInfo()
 </script>
 <script type="text/html" id="orderStatus">
     {{#  if(d.acceptStatus==0) { }}
     <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px"> <a href="">接受订单</a></button>
     {{#  }else if(d.finishStatus==0 && d.acceptStatus==1){  }}
     <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px"> <a href="">完成订单</a></button>
     {{# } else if(d.finishStatus==1 && d.commentStatus==0){  }}
     <button class="layui-btn layui-btn-sm layui-col-md-offset10"  style="margin-bottom: 10px"> <a href="">评论订单</a></button>
     {{# } }}
 </script>
</body>
</html>
